/*
 * @Author: miteng 973203639@qq.com
 * @Date: 2023-12-21 09:19:21
 * @LastEditors: 郝奔 1425466221@qq.com
 * @LastEditTime: 2024-08-09 14:12:01
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
/**
 * window.localStorage 浏览器永久缓存
 */
export const localStorage = {
  // 设置永久缓存
  set(key: string, val: string | boolean | number | null | [] | undefined): void {
    window.localStorage.setItem(key, JSON.stringify(val));
  },
  // 获取永久缓存
  get(key: string): string {
    const json = window.localStorage.getItem(key) as string;
    return JSON.parse(json);
  },
  // 移除永久缓存
  remove(key: string): void {
    window.localStorage.removeItem(key);
  },
  // 移除全部永久缓存
  clear(): void {
    window.localStorage.clear();
  }
};

// 侧边栏状态(显示/隐藏)
const SidebarStatusKey = 'sidebarStatus';
export function getSidebarStatus(): string {
  return localStorage.get(SidebarStatusKey);
}

export function setSidebarStatus(sidebarStatus: string): void {
  localStorage.set(SidebarStatusKey, sidebarStatus);
}
// 布局大小
const SizeKey = 'size';

export function getSize(): string {
  return localStorage.get(SizeKey);
}

export function setSize(size: string): void {
  localStorage.set(SizeKey, size);
}

// 语言
const LanguageKey = 'language';

export function getLanguage(): string {
  return localStorage.get(LanguageKey);
}

export function setLanguage(language: string): void {
  localStorage.set(LanguageKey, language);
}

// 应用id
const ApplicationId = 'applicationId';

export function getApplicationId(): string {
  return localStorage.get(ApplicationId);
}

export function setApplicationId(Id: string): void {
  localStorage.set(ApplicationId, Id);
}

// 应用信息
const ApplicationInfo = 'applicationInfo';

export function getApplicationInfo(): string {
  return localStorage.get(ApplicationInfo);
}

export function setApplicationInfo(data: string): void {
  localStorage.set(ApplicationInfo, data);
}
